package com.jerry.template.module.home.activity;

import android.support.v4.app.Fragment;
import android.widget.RadioGroup;

import com.jerry.template.R;
import com.jerry.template.base.BaseActivity;
import com.jerry.template.base.BaseFragment;
import com.jerry.template.module.mainpage.find.fragment.FindFragment;
import com.jerry.template.module.mainpage.msg.fragment.MsgFragment;
import com.jerry.template.module.mainpage.check.fragment.CheckFragment;
import com.jerry.template.module.mainpage.shouye.fragment.HomePageFragment;

import butterknife.BindView;

/**
 * Created by chenhuan on 2016/5/10.
 */
public class HomeActivity extends BaseActivity{

    @BindView(R.id.bottom_group)
    RadioGroup bottomGroup;



    @Override
    protected int getLayoutId(){
        return R.layout.activity_home;
    }

    @Override
    protected void initViews(){

        HomePageFragment defaultFragment = BaseFragment.newInstance(HomePageFragment.class,null);
        getSupportFragmentManager().beginTransaction().replace(R.id.home_frag,defaultFragment).commit();

        bottomGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId){
                Fragment fragment = null;
                switch(checkedId){
                    case R.id.shouye:
                        fragment = BaseFragment.newInstance(HomePageFragment.class,null);
                        getSupportFragmentManager().beginTransaction().replace(R.id.home_frag,fragment).commit();
                        break;
                    case R.id.faxian:
                        fragment = BaseFragment.newInstance(FindFragment.class,null);
                        getSupportFragmentManager().beginTransaction().replace(R.id.home_frag,fragment).commit();
                        break;
                    case R.id.shenhe:
                        fragment = BaseFragment.newInstance(CheckFragment.class,null);
                        getSupportFragmentManager().beginTransaction().replace(R.id.home_frag,fragment).commit();
                        break;
                    case R.id.xiaoxi:
                        fragment = BaseFragment.newInstance(MsgFragment.class,null);
                        getSupportFragmentManager().beginTransaction().replace(R.id.home_frag,fragment).commit();
                        break;
                    default:
                        break;
                }
            }
        });


    }
}
